<template>
  <div class="app">
    我是APP组件
    <SonA></SonA>
    <SonB></SonB>
    <button @click="changeData">修改数据</button>
  </div>
</template>

<script>
import SonA from "./components/SonA.vue";
import SonB from "./components/SonB.vue";
export default {
  // 父组件提供数据
  provide() {
    return {
      // 普通数据【非响应式】
      color: this.color,
      // 引用数据 【响应式】
      userInfo: this.userInfo,
    };
  },
  data() {
    return {
      color: "pink",
      userInfo: {
        name: "zs",
        age: 18,
      },
    };
  },
  components: {
    SonA,
    SonB,
  },
  methods: {
    changeData() {
      // this.color = "red";
      this.userInfo.name = "不知火舞";
    },
  },
};
</script>

<style>
.app {
  border: 3px solid #000;
  border-radius: 6px;
  margin: 10px;
}
</style>